import java.util.ArrayList;
import java.util.Random;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 23735
 * Date: 2022-09-26
 * Time: 19:28
 */

class Card{

    private int rank;
    private String flower;


    public Card(int rank, String flower) {
        this.rank = rank;
        this.flower = flower;
    }

    @Override
    public String toString() {
        return "["+this.rank+" "+this.flower+"]";
    }
}


public class Poker {


    private final String[] str={"♠","♦","♣","♥"};

    //造牌
    public ArrayList<Card> buyCard(){
        ArrayList<Card> list=new ArrayList<>();
        for (int i = 1; i <= 13; i++) {
            for (int j = 0; j < 4; j++) {
                list.add(new Card(i,str[j]));
            }
        }
        return list;
    }

    //洗牌
    public void shuffle(ArrayList<Card> list){
        Random random=new Random();
        for (int i = list.size()-1; i >0 ; i--) {
            int ret=random.nextInt(i);//注意i不能为0
            swap(list,i,ret);
        }
    }

    private void swap(ArrayList<Card> list,int index1,int index2){
        Card card=list.get(index1);
        list.set(index1,list.get(index2));
        list.set(index2,card);
    }

    //发牌
    public void allocCard(ArrayList<Card> list,ArrayList<Card> hand){
        for (int i = 0; i < 5&&list.size()>0; i++) {
           Card card=list.remove(0);
            hand.add(card);
        }
        if(list.size()==0){
            System.out.println("牌已发完");
        }
    }


    public void display(ArrayList<Card> list){
        for (int i = 0;  i<list.size() ; i++) {
            System.out.print(list.get(i)+" ");
        }
        System.out.println();
    }

}
